#encoding=utf-8
import hiai
from hiai.nn_tensor_lib import DataType
import cv2 as cv
import threading
import yolov3manager
import graph
import dvpp_process.dvpp_process as dp
import numpy as np
import os
import DetectionManager

count = 1
def crop_image(detection_list,save_path):
    global count
    for obj in detection_list:
        # save_image = img[ymin:ymax, xmin:xmax]
        save_image = img[obj.lt.y:obj.rb.y, obj.lt.x:obj.rb.x]
        save_file_path=save_path+str(count)+"_"+str(obj.object_class)+".jpg"
        cv2.imwrite(save_file_path, save_image)
        count +=1

def main():
    detction = DetectionManager.DetectionManager()
    images_path='/home/HwHiAiUser/img/'
    for filename in os.listdir(images_path):
        detection_list = detction.inference_from_file(images_path+filename)
        print('detection_list is :', len(detection_list))
        print(detection_list[0].object_class)
        print(detection_list[0].confidence)
        print(detection_list[0].lt.x)
        print(detection_list[0].lt.y)
        print(detection_list[0].rb.x)
        print(detection_list[0].rb.y)
        print('----------------------------------')
    
  
if __name__ == "__main__":
    main()
